export function transIdWords(i) {
    let str;
    switch (i) {
        case 1:
            str = "攻击力";
            break;
        case 2:
            str = "生命值";
            break;
        case 3:
            str = "防御力";
            break;
        case 4:
            str = "攻击力";
            break;
        case 5:
            str = "生命值";
            break;
        case 6:
            str = "防御力";
            break;
        case 7:
            str = "精通";
            break;
        case 8:
            str = "充能";
            break;
        case 9:
            str = "暴击率";
            break;
        case 10:
            str = "暴击伤害";
            break;
        case 11:
            str = "治疗加成";
            break;
        case 12:
            str = "物理伤害提升";
            break;
        case 13:
            str = "水元素伤害提升";
            break;
        case 14:
            str = "火元素伤害提升";
            break;
        case 15:
            str = "冰元素伤害提升";
            break;
        case 16:
            str = "岩元素伤害提升";
            break;
        case 17:
            str = "雷元素伤害提升";
            break;
        case 18:
            str = "风元素伤害提升";
            break;
        case 19:
            str = "草元素伤害提升";
            break;
        default:
            str = ""
    }
    return str;
}

export const lwImageArray = [require("../assets/artifact/lw1.png"),
    require("../assets/artifact/lw2.png"),
    require("../assets/artifact/lw3.png"),
    require("../assets/artifact/lw4.png"),
    require("../assets/artifact/lw5.png")];
export const cwImageArray = [
    require("../assets/artifact/cw1.png"),
    require("../assets/artifact/cw2.png"),
    require("../assets/artifact/cw3.png"),
    require("../assets/artifact/cw4.png"),
    require("../assets/artifact/cw5.png")
];

export function generateSuit(artifactInfoList, seed,flag) {

    let suit = []
    let j = seed;
    for (const elemnt of artifactInfoList) {
        let artifact = {};
        artifact.words = [];
        artifact.id = j++;
        artifact.src = elemnt[20] === 0 ? cwImageArray[elemnt[0]] : lwImageArray[elemnt[0]];
        const mainType = elemnt[23];
        let k = 1;
        for (let i = 1; i < 19; i++) {
            let str = transIdWords(i);
            let proValue = elemnt[i];
            if (proValue === 0 && proValue === undefined) {
                continue
            }
            let valStr = "";

            if (proValue < 1) {
                valStr = proValue.toLocaleString('en-us', {
                    style: 'percent', maximumSignificantDigits: 3
                });
            } else {
                valStr = proValue.toLocaleString();
            }
            const id = String(i + seed);
            if (proValue > 0 && i !== mainType) {
                artifact.words[k] = ({id: id, text: str + "+ " + valStr});
                k++;
            }
            if (i === mainType) {
                artifact.words[0] = ({id: id, text: str + "+ " + valStr});
            }
        }
        if(flag){
            artifact.words[5] = ({id: -1, text: "分数+ " + elemnt[22].toLocaleString()})
        }
        suit.push(artifact)
    }
    return suit;
}
